package com.njym.payment.wxpay.api;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Configure {
	public static final String WX_PlACE_ORDER="https://api.mch.weixin.qq.com/pay/unifiedorder";//微信统一下单接口
	
	public static final String NOTIFY_URL=" "; //微信支付回调地址
	
	public static final String APP_ID="wx12b3be629299535f";//微信公众号appid
	
	public static final String APP_SECRET="8a1b1799be62fc68f4047d82b73b3609"; //微信公众号密钥
	
	public static final String WX_GET_CODE_URL="https://open.weixin.qq.com/connect/oauth2/authorize?appid=APP_ID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect";//微信获取codeurl
	
	public static final String WX_GET_ACCESS_URL="https://api.weixin.qq.com/sns/oauth2/access_token?appid=APP_ID&secret=APP_SECRET&code=USE_CODE&grant_type=authorization_code";//获取用户openid地址
	
	public static final String WX_GET_USER_INFO_URL="https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPEN_ID&lang=zh_CN";
	
	public static final String KEY="uv5qfIjSN7aO7c8YSFheI2m2ceQBYVti";//支付密钥
	
	public static final String PAY_ID="1509086281";//商户id

	@Bean
	public WxPayConfig wxPayConfig() {
		WxPayConfig payConfig = new WxPayConfig();
		payConfig.setAppId(APP_ID);
		payConfig.setMchId(PAY_ID);
		payConfig.setMchKey(KEY);
		payConfig.setNotifyUrl("http://24r22a9521.wicp.vip/server/wxpay_api/unifiedorder_notify");
		payConfig.setKeyPath("E:\\njymchpp\\apiclient_cert.p12");
		payConfig.setTradeType("JSAPI");
		payConfig.setSignType("MD5");
		return payConfig;
	}

	@Bean
	public WxPayService wxPayService(WxPayConfig payConfig) {
		WxPayService wxPayService = new WxPayServiceImpl();
		wxPayService.setConfig(payConfig);
		return wxPayService;
	}
}
